<form action="index.php/suppliers/edit/" method="post" name="myform"  id="myform">
<div id="inline1">
<h2><span>供应商</span></h2>
<table>
    <tr><th colspan="5">基本信息：</th></tr>
    <tr>
        <td class="name" width="80"><span>*</span>供应商：</td>
      	<td width="170" colspan="4">
        <input type="text" id="name" name="name" style=" width:427px;" class="text_width" autocomplete="off" value="<?=$update_suppliers->name?>" ></input>
    </tr>
    <tr>
        <td class="name" width="80">类别：</td>
        <td width="170">
        	<select name="type" id="type">
        		<option value=0>请选择类别</option>
            	<option value="1" <?php if($update_suppliers->type == '设备'):?> selected="selected" <?php endif;?>>设备</option>
                <option value="2" <?php if($update_suppliers->type == '开发'):?> selected="selected" <?php endif;?>>开发</option>
                <option value="3" <?php if($update_suppliers->type == '服务'):?> selected="selected" <?php endif;?>>服务</option>
                <option value="4" <?php if($update_suppliers->type == '其他'):?> selected="selected" <?php endif;?>>其他</option>
            </select>
        </td>
        <td colspan="3">&nbsp;</td>
        
    </tr>
    <tr><th colspan="5">联系人信息：</th></tr>
    <tr>
        <td class="name" width="80"><span>*</span>联系人：</td>
        <td width="170"><input type="text" name="contacter_one" id="contacter_one"  value="<?=$update_suppliers->contacter_one?>" ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80">联系方式：</td>
        <td width="170" class="ie_6"><input type="text" name="tel_1" value="<?=$update_suppliers->tel_1?>"></input></td>
    </tr>
    <tr>
        <td class="name" width="80">职务：</td>
        <td width="170" colspan="4"><input type="text" name="post_one" value="<?=$update_suppliers->post_one?>" ></input></td>
        
    </tr>
    <tr>
        <td class="name" width="80">联系人：</td>
        <td width="170"><input type="text" name="contacter_two" value="<?=$update_suppliers->contacter_two?>" ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80">联系方式：</td>
        <td width="170" class="ie_6"><input type="text" name="tel_2" value="<?=$update_suppliers->tel_2?>"></input></td>
    </tr>
    <tr>
        <td class="name" width="80">职务：</td>
        <td width="170" colspan="4"><input type="text" name="post_two" value="<?=$update_suppliers->post_two?>" ></input></td>
        
    </tr>
    <tr><th colspan="5">供应商信息：</th></tr>
    <tr>
        <td class="name" width="80">所属区域：</td>
        <td width="170">
        	<select name="region_id" id="dirtrict">
	            <option value=0>请选择</option>
				<?php foreach($region as $item):?>
					<option value=<?= $item->id?> <?php if($update_suppliers->region_id == $item->id):?> selected="selected" <?php endif;?>><?= $item->district?></option>
				<?php endforeach;?>
	        </select>
        </td>
        <td>&nbsp;</td>
        <td class="name" width="80">地址：</td>
        <td width="170"><input type="text" name="address" value="<?=$update_suppliers->address?>" ></input></td>
    </tr>
    <tr>
        
        
        <td class="name" style="padding:0px;">累计合同金额：</td>
        <td width="170"><input type="text" class="input_bg" name="outside_contract_money" id="outside_contract_money" value="<?php if($update_suppliers->outside_contract_money):?><?=$update_suppliers->outside_contract_money?><?php endif;?>"></input></td>
        <td>&nbsp;</td>
        <td class="name">经营范围：</td>
        <td width="170"><input type="text" name="operate_scope" value="<?=$update_suppliers->operate_scope?>" ></input></td>
    </tr>
    <tr>
        <td class="name" width="80" >累计合同：</td>
        <td width="170" colspan="3"><input type="text" name="outside_contract_nums" id="outside_contract_nums" value="<?php if($update_suppliers->outside_contract_nums):?><?=$update_suppliers->outside_contract_nums?>份<?php endif;?>" ></input></td>
    </tr>
    
    <tr><td colspan="5">&nbsp;</td></tr>
    <tr class="sub">
        <td colspan="5"><input type="button" id="update_tijiao" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" /></td>
    </tr>
</table>
</div>
<input type="hidden" name="suppliers_id" value="<?=$update_suppliers->suppliers_id?>" ></input>
</form>
<script type="text/javascript">
	$(function(){
		$("#update_tijiao").click(function(){
			var suppliers_name = $.trim($("#name").val());
			var contacter_one = $.trim($("#contacter_one").val());
			var type = $("#type").val();
			var dirtrict = $("#dirtrict").val();
			var outside_contract_nums = $("#outside_contract_nums").val();
			var outside_contract_money = $("#outside_contract_money").val();

			if(!suppliers_name || !contacter_one || type == 0 || dirtrict == 0){
				if(!suppliers_name){
					alert('供应商不允许为空');
					$("#name").focus();
				}
				if(!contacter_one){
					alert('联系人1不允许为空');
					$("#contacter_one").focus();
				}
				
				if(type == 0){
					alert('确定不选择类别,提交？');
				}

				if(dirtrict == 0){
					alert('确定不选择区域,提交？');
				}
			}else{
				var re = /^[0-9]+.?[0-9]*$/;
				if(outside_contract_nums || outside_contract_money){
					if (!re.test(outside_contract_nums) || !re.test(outside_contract_money)){
						alert('合同数/金额,输入需要是数字');
					}else{
						$("#myform").submit();
					}
				}else{
					$("#myform").submit();
				}
			}
		})
	})
</script>




